#include <Lpc23xx.h>
#include "LCD.h"
void EXTINTVectoredIRQ (void)__irq;
unsigned int flasher = 0x0000000; 	
int main (void)
{
    
unsigned int delay; //
	/* Reset all GPIO pins to default: primary function */
    PINSEL0 = 0x00000000;
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    PINSEL3 = 0x00000000;
    PINSEL4 = 0x00000000;
    PINSEL5 = 0x00000000;
    PINSEL6 = 0x00000000;
    PINSEL7 = 0x00000000;
    PINSEL8 = 0x00000000;
    PINSEL9 = 0x00000000;
    PINSEL10 = 0x00000000;
    
    IODIR0 = 0x00000000;
    IODIR1 = 0x00000000;
	  IOSET0 = 0x00000000;
    IOSET1 = 0x00000000;
    
    FIO0DIR = 0x00000000;
    FIO1DIR = 0x00000000;
    FIO2DIR = 0x00000000;
    FIO3DIR = 0x00000000;
    FIO4DIR = 0x00000000;
    
    FIO0SET = 0x00000000;
    FIO1SET = 0x00000000;
    FIO2SET = 0x00000000;
    FIO3SET = 0x00000000;
    FIO4SET = 0x00000000;					

    FIO2DIR = 0x000000FF;
    FIO2MASK = 0xFFFFFF00; 
    PINSEL4 	= 0x00100000;						            //Enable the EXTINT1 interrupt
    
    IO2_INT_CLR         = 0xFFFFFFFF;
    IO2_INT_EN_R        = 0xFFFFFF00;

    VICVectPriority17 	= 0x00000000;  				    //Set Slot 17 to the highest priority
    VICVectAddr17	= (unsigned)EXTINTVectoredIRQ;  //pass the address of the IRQ into the VIC slot
    VICIntEnable 	= 0x00020000;					          //enable interrupt
	lcd_init();					   //
	lcd_clear();				  //
	set_cursor(1,0);			   // Agaf=/
    lcd_print("GPIO intterupt");	 //
	set_cursor(4,1);
	lcd_print("Example");
    while(1)
    {
    FIO2CLR = 0x000000FF;

    for(flasher =1;flasher<0x00000010;flasher = flasher <<1)
    {
       FIO2SET = flasher; 
        for(delay = 0;delay<0xA0000;delay++)				  	//simple delay loop
        {
          ;
        }
      }
    FIO2CLR = 0x000000FF;
  
}
    
//return (0);    
}


void EXTINTVectoredIRQ (void) __irq 
{

FIO2SET         = 0x000000F0;           //Switch on thelower nibble LEDs

IO2_INT_CLR = IO2_INT_STAT_R ;
VICVectAddr 	= 0x00000000;					   //Dummy write to signal end of interrupt
}
/************************************** EOF *********************************/
